<template>
   <div class="fly-panel" v-show="lists.length > 0">
      <div class="fly-panel-title fly-filter">
        <a>置顶</a>
        <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin" style="color: #FF5722;">去签到</a>
      </div>
      <ListItem :lists="lists" :isShow="false"></ListItem>
    </div>
</template>

<script>
import ListItem from './ListItem'
import { getList } from '@/api/content.js'
export default {
  name: 'top',
  components: {
    ListItem
  },
  data () {
    return {
      isTop: 1,
      page: 0,
      limit: 5,
      lists: []
    }
  },
  mounted () {
    this._getList()
  },
  methods: {
    _getList () {
      // if (this.isRepeat || this.isEnd) {
      //   return false
      // }
      this.isRepeat = true
      const options = {
        isTop: 1,
        limit: this.limit,
        page: this.page
      }
      getList(options).then(res => {
        if (res.code === 200) {
          if (res.data.length < this.limit) {
            this.isEnd = true
          }
          if (this.lists.length) {
            this.lists = this.lists.concat(res.data)
          } else {
            this.lists = res.data
          }
        }
      }).catch((err) => {
        if (err) {
          this.$alert(err)
        }
      }).finally(() => {
        this.isRepeat = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
